<template>
  <div class="page">
    <div class="p20">
      刷币资金总额：{{ alone.rewardTotal }} <span class="ml20">单位：元</span>
    </div>
    <el-divider></el-divider>
    <div class="s-search p20">
      <el-form
        :model="alone.searchForm.data"
        status-icon
        ref="ruleForm"
        :inline="true"
        class="demo-ruleForm"
      >
        <el-form-item>
          <el-input
            placeholder="请输入标题搜索"
            v-model="alone.searchForm.data.title"
          >
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-select v-model="alone.searchForm.data.businessType">
            <el-option label="全部" value=""></el-option>
            <el-option
              v-for="item in alone.businessType"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="rSubmitSearchForm">搜索</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="c-main p20">
      <div class="clearfix">
        <!-- <div class="fl">总共：{{ pageAjax.paging.total }} 条</div> -->
      </div>
      <div class="c-section">
        <div class="c-body">
          <el-table :data="pageAjax.data" stripe style="width: 100%">
            <el-table-column type="index" label="序号"> </el-table-column>
            <el-table-column label="标题">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.title || "无" }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="申请人">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.applyName }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="请款业务类型">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.businessType }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="金额(元)">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.amount }}
                </div>
              </template>
            </el-table-column>
            <el-table-column label="申请日期">
              <template slot-scope="scope">
                <div class="">
                  {{ scope.row.applyTime }}
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="c-footer">
          <div class="c-pagination">
            <el-pagination
              layout="prev, pager, next"
              @current-change="rPagingChange"
              @prev-click="rPagingChange"
              @next-click="rPagingChange"
              :current-page="pageAjax.paging.current"
              :total="pageAjax.paging.total"
            >
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { getRewardTotalList } from "@/api/finance.js";
import _ from "lodash";

export default {
  name: "agent_signedList",
  data: () => ({
    pageAjax: {
      btnDisabled: false,
      btnLoading: false,
      loading: false,
      lock: false,
      paging: {
        pages: 1, // 总页数
        current: 0, // 当前页
        total: 1, // 总数量
        pageSize: 10 // 每页数量
      },
      data: []
    },
    biPlatformListSupAjax: {
      data: []
    },
    alone: {
      rewardTotal: 0,
      businessType: [
        {
          name: "针对性主播扶持",
          value: "针对性主播扶持"
        },
        {
          name: "主播日常扶持",
          value: "主播日常扶持"
        },
        {
          name: "艺人推广",
          value: "艺人推广"
        },
        {
          name: "艺人其他扶持",
          value: "艺人其他扶持"
        }
      ],
      signStatus: "SIGNED",
      searchForm: {
        loading: false,
        data: {
          title: "",
          businessType: "",
          deptId: "",
          operatorId: ""
        }
      }
    },
    translate: {
      biPlatformList: {}
    }
  }),
  created() {
    let _that = this;
    _that.alone.rewardTotal = _that.$route.query.total || 0;
    _that.alone.searchForm.data.deptId = _that.$route.query.id
      ? _that.$route.query.id
      : "";
    _that.alone.searchForm.data.operatorId = _that.$route.query.uid
      ? _that.$route.query.uid
      : "";

    _that.getPageData();
  },
  mounted() {},
  methods: {
    rSubmitSearchForm() {
      let _that = this;
      if (_that.pageAjax.loading) {
        return;
      }
      _that.pageAjax.lock = false;
      _that.pageAjax.paging.current = 0;
      // if (!searchForm.data.searchStr && !searchForm.data.signWish && !searchForm.data.platform) {
      //   _that.$message.error({message: "搜索条件不能都为空", onClose: () => {
      //     _that.alone.searchForm.loading = false;
      //   }});
      //   return;
      // }
      _that.pageAjax.lock = false;
      _that.pageAjax.paging.current = 0;
      _that.getPageData();
    },
    rPagingChange(e) {
      let _that = this;
      _that.pageAjax.paging.current = e - 1;
      _that.getPageData();
    },
    getPageData() {
      let _that = this;
      let searchForm = _.cloneDeep(_that.alone.searchForm);
      let pageAjax = _that.pageAjax;

      if (pageAjax.loading || pageAjax.lock) {
        return;
      }

      let data = { ...searchForm.data };

      data.pageNo = _that.pageAjax.paging.current + 1;
      _that.pageAjax.loading = true;
      getRewardTotalList(data)
        .then(resp => {
          let respData = resp.data || {};
          let respResult = respData.data || {};

          if (respData.code === _that.STATUS.success[0]) {
            _that.pageAjax.data = respResult.list || [];
            if (respResult.pagination) {
              _that.pageAjax.paging = {
                pages: respResult.pagination.pages,
                current: respResult.pagination.current,
                total: respResult.pagination.total,
                pageSize: respResult.pagination.pageSize
              };
            }
          } else {
            _that.$message.error(respData.msg || "获取失败");
          }
        })
        .finally(() => {
          _that.pageAjax.loading = false;
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.page {
  .s-search {
    border-bottom: 1px solid #eee;
  }
  .c-aside {
    .btn {
      margin-right: 20px;
    }
    .diy-uploadBtn {
      margin-right: 20px;
    }
  }
  .c-main {
    margin-top: 20px;
    .c-avatar {
      display: block;
      width: 100px;
      height: 100px;
      border-radius: 50%;
    }
  }
  .c-pagination {
    margin-top: 20px;
    text-align: center;
  }
  .f-agentWish {
    overflow: hidden;
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    .c-content {
      height: 100%;
      padding-bottom: 20px;
      overflow: auto;
    }
    .c-card {
      .c-item {
        padding-bottom: 20px;
        border-top: 1px solid #f5f7fa;
      }
      .c-UserInfo {
        position: relative;
        overflow: hidden;
        line-height: 25px;
      }
      .c-avatar {
        float: left;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .c-nameInfo {
        float: left;
        margin-left: 20px;
      }
      .c-copyBtn {
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 0;
        border: 1px solid #eee;
        padding: 10px 20px;
        border-radius: 20px;
      }
      .c-bid {
        overflow: hidden;
        line-height: 30px;
        img {
          float: left;
          width: 30px;
          height: 30px;
          margin-right: 20px;
        }
      }
    }
  }
  .f-agent {
    overflow: hidden;
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    .c-content {
      height: 100%;
      padding-bottom: 20px;
      padding-top: 60px;
      overflow: auto;
    }
    .c-avatar {
      width: 80px;
      height: 80px;
    }
  }
}
</style>
<style lang="scss">
.page {
  .el-drawer__header {
    position: relative;
    z-index: 10;
  }
}
</style>
